let nums1 = [1,2,2,1], nums2 = [2,2]
function set_intersection(set1,set2){
    let arr = []
    for(let item of set1){
        if(set2.has(item)){
            arr.push(item)
        }
    }
    return arr
}
var intersection = function(nums1, nums2) {
    let set1 = new Set(nums1)
    let set2 = new Set(nums2)
     return set_intersection(set1, set2);
}
console.log(intersection(nums1,nums2));


